package com.aliyun.heiyu.powermaster.server.strategy.analyzer;

import com.aliyun.heiyu.powermaster.proto.PowerStrategy;
import com.aliyun.heiyu.powermaster.proto.StrategyAction;
import com.aliyun.heiyu.powermaster.server.manager.ThunderManager;
import com.aliyun.heiyu.powermaster.server.manager.ThunderManagerImpl;
import com.aliyun.heiyu.powermaster.server.MasterConstant;
import com.aliyun.heiyu.powermaster.server.strategy.action.PowerOffAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class AIPowerOffStrategyAnalyzer extends StrategyAnalyzer {
    private static final Logger logger = LoggerFactory.getLogger(AIPowerOffStrategyAnalyzer.class);
    private ThunderManager thunderManager;

    public AIPowerOffStrategyAnalyzer() {
        super(MasterConstant.AI_POWEROFF, PowerStrategy.POWER_OFF.name());
        this.thunderManager = new ThunderManagerImpl();
    }

    @Override
    protected Boolean monitorCondition(StrategyAction strategyAction, String sn, String level) {
        logger.debug("监控设备  == "+sn+"ai poweroff条件");
        if("3".equals(level)){
            return powerOffJudge(sn);
        }else{
            return statusJudge(sn);
        }
    }

    @Override
    protected Boolean isTrue(String sn) {
        boolean status = PowerOffAction.getInstance().isExist(sn);
        return status;
    }

    private Boolean statusJudge(String sn){
        boolean status = PowerOffAction.getInstance().isExist(sn);
        if(status){
            return false;
        }
        return null;
    }

    private Boolean powerOffJudge(String sn){
        boolean status = PowerOffAction.getInstance().isExist(sn);
        if(!status){
            return Boolean.TRUE;
        }
        return null;
    }
}
